/*
 * @Author: zjj
 * @Date: 2020-02-19 09:31:30
 * @LastEditors: zjj
 * @LastEditTime: 2020-02-22 11:15:41
 */
/*
 * @Author: zjj
 * @Date: 2019-11-23 13:20:23
 * @LastEditors: zjj
 * @LastEditTime: 2020-02-21 09:59:14
 */
import Vue from 'vue'
import './cube-ui'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
// FastClick
// import  FastClick  from  'fastclick'
// FastClick.attach(document.body);

// 移动端适配 
import 'lib-flexible' 
//适配部分fontsize问题的华为手机
import "./utils/huawei.js"
//swiper
import VueAwesomeSwiper from 'vue-awesome-swiper'
// require styles
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper, /* { default global options } */)
//引入字体
// import "./assets/style/font.css"
//导入全局样式
import "./assets/style/reset.styl"
import "./assets/style/base.styl"
import "./assets/style/global.less"

// 引入vant
import { Stepper,Area,Popup,Rate,Notify,Dialog ,SwipeCell,Field,Uploader ,Loading,ActionSheet ,ImagePreview ,Checkbox,DatetimePicker,Icon   } from 'vant';
Vue.use(Stepper);
Vue.use(Area);
Vue.use(Popup);
Vue.use(Rate);
Vue.use(Notify);
Vue.use(Field);
Vue.use(SwipeCell);
Vue.use(Uploader);
Vue.use(Loading);
Vue.use(ActionSheet);
Vue.use(ImagePreview);
Vue.use(Dialog);
Vue.use(Checkbox);
Vue.use(DatetimePicker);
Vue.use(Icon);


//路由拦截 注意要放在new Vue之前，不然第一次启动页面时无效
// 剪切板
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

router.beforeEach((to, from, next) => {
  if (!store.state.routes.includes(to.path)) {
    store.commit('addRoute', to.path)
  }
  window.onscroll=null
  if (to.matched.some(record => record.meta.needLogin)) {
    // this route requires auth, check if logged in
    // if not, redirect to login page.
    if (!store.state.isLogin) {
      next({
        path: '/login',
        // query: { redirect: to.fullPath }
      })
    } else {
        next()
    }
    // next()
  } else {
    next() // 确保一定要调用 next()
  }

})

//rxjs
import VueRx from 'vue-rx';

Vue.use(VueRx);

//webSocket
import WS from "./utils/websocket"
WS.start()
// import VConsole from "vconsole"
// var vConsoleInstance = new VConsole();
// Vue.use(vConsoleInstance)
import positioning from "./utils/postion"
positioning.startPosition()

Vue.filter('toFixed', function (value) {
  return value.toFixed(2)
})
//企业册
import ZHeader from "./components/z-header"
Vue.component("z-header", ZHeader)
import ZBody from "./components/z-body"
Vue.component("z-body", ZBody)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
